package java56_6;

import java.util.Scanner;

public class GuessNum {

	public static void main(String[] args) {
		// 猜数
		int[] num = { 8, 4, 1, 23, 844, 12 };
		// 输出
		for (int i : num)
			System.out.print(i + "   ");
		System.out.println();
		int sum = 0;
		for (int i : num)
			sum += i;
		System.out.println("和是" + sum);

		Scanner sc = new Scanner(System.in);
		boolean in = false;
		System.out.println("请输入要猜的数：");
		int k = sc.nextInt();
		for (int i = 0; i < num.length; i++) {
			if (num[i] == k) {
				System.out.println("找到了，是第" + (i + 1) + "处");
				in = true;
				return;
			}/*
			 * else { System.out.println("不在"); }
			 */

		}
		if (!in)
			System.out.println(k + "不在数组中");
	}

}
